<%@ page language="java" %>
<%
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("max-age", 0);
    response.setDateHeader("Expires", 0);
%>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.commons.SessionKeys"%>
<%@ page import="com.scalar.chiptrack.utils.StringUtils" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<html>

<HEAD>
	<TITLE>ScalarSoft - ChipTrac - attach file</TITLE>
    <META http-equiv='Content-Type' content='text/html; charset=windows-1252'>
    <LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>
	<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
    <script>
        function deleteAttachedFile(id) {
            var form = document.attachFileForm;
            form.action = "<%=chipTracContext%>/attachFile.do?action=deleteAttachedFile&id="+id;
            form.submit();
        }
    </script>
</HEAD>

<BODY bgcolor='ffffff' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0'>
<logic:present name="sessionExpired" scope="request">
    <TABLE cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
        <TR>
            <TD>
                <TABLE align="center" border="0" width="40%" bgcolor="#FDF5E6">
                    <TR><TD>&nbsp;</TD></TR>
                    <TR><TD align="center" ><font class="NArialL" ><font color="red"><b>Session has been time out , Please close this window and login again.</b></font></font></TD></TR>
                    <TR><TD>&nbsp;</TD></TR>
                    <TR><TD align="center" ><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></TD></TR>
                </TABLE>
            </TD>
       </TR>
       <TR><TD>&nbsp;</TD></TR>
    </TABLE>
</logic:present>
<logic:notPresent name="sessionExpired" scope="request">
<html:form name="attachFileForm" type="com.scalar.chiptrack.commons.forms.AttachFileForm" action="/attachFile.do?action=saveAttachedFile" enctype="multipart/form-data">
<div align="right"><a href="javascript:window.close();"><font class='NArialL'>[Close this window]</font></a></div>    
<table align='center' border='0'>
    <tr>
        <td colspan='2' align='center' class="NArialW"><bean:write name="attachFileForm" property="formTitle"/></td>
    </tr>
     <tr>
        <td colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td>
    </tr>
    <tr>
        <td colspan='2' class="NArialL">
            <FONT id="errors" color='FF0000'></font>
            <chiptrack:errors styleClass="NArialL"/>
            <chiptrack:info styleClass="NArialL"/>
        </td>
    </tr>
    <nested:hidden property="fileGroup"/>
    <nested:hidden property="fileSubGroup"/>
    <nested:hidden property="allowMultiple"/>
    <nested:hidden property="allowAttach"/>
    <nested:hidden property="allowDelete"/>
    <nested:hidden property="linkText"/>
    <nested:hidden property="formTitle"/>
    <logic:equal value="true" property="allowAttach" name="attachFileForm">
        <tr>
            <td class='NArialL'>Attach File:</td>
            <td class='NArialL'><html:file property="attachedFormFile" styleClass="txfield"/></td>
        </tr>
        <tr>
            <td class='NArialL'>Comments:</td>
            <td class='NArialL'><html:textarea property="comments" styleClass="txfield" rows="6" cols="40"/></td>
        </tr>
        <tr>
            <td colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td>
        </tr>
        <tr>
            <td colspan='2' align="middle">
                <input type="image" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" border='0' title="Click here to Save attachment" >
                &nbsp;&nbsp;&nbsp;
                <a href="javascript:document.attachFileForm.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click  to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
                &nbsp;&nbsp;&nbsp;
                <a href="javascript:window.close();"><img src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" border='0' onmouseover="window.status='Click  to cancel';return true" onmouseout="window.status='';return true" title="Click here to Cancel"></a>
            </td>
        </tr>
    </logic:equal>
    <tr>
        <td colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td>
    </tr>
</table>
<table border="0" width="55%" align="center">
    <tr class="NArialS">
        <td colspan="5" align="left" class="NArialS">[Click on attached file name to download]</td>
    </tr>
    <tr class="NArialL">
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
            Attached File Name
        </font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
            Comments</font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
           Attached By User</font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
           Attached On</font></td>
        <td align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">
            Actions</font></td>
    </tr>
    <logic:iterate name="attachedFileList" id="attachedFile"
                   type="com.scalar.chiptrack.commons.AttachedFile" indexId="index">

        <tr class="NArialL">
            <td align="center" bgcolor="<%=index%2==0 ?"#D8D8D8":"#ffffee"%>" class="NArialL">
                <a href="<%=chipTracContext%><bean:write name="attachedFile" property="fileLinkEncoded"/>"><bean:write name="attachedFile" property="fileName"/></a>
            </td>
            <td align="center" bgcolor="<%=index%2==0 ?"#D8D8D8":"#ffffee"%>" class="NArialL">
                <bean:write name="attachedFile" property="comments"/>
            </td>
            <td align="center" bgcolor="<%=index%2==0 ?"#D8D8D8":"#ffffee"%>" class="NArialL">
                <bean:write name="attachedFile" property="attachedByUserId"/>
            </td>
            <td align="center" bgcolor="<%=index%2==0 ?"#D8D8D8":"#ffffee"%>" class="NArialL">
                <%=StringUtils.formatDateToString(attachedFile.getTimeStamp())%>
            </td>
            <td align="center" bgcolor="<%=index%2==0 ?"#D8D8D8":"#ffffee"%>" class="NArialL" nowrap> 
                <logic:equal value="true" property="allowDelete" name="attachFileForm">
                    <a href="javascript:deleteAttachedFile(<bean:write property="id" name="attachedFile"/>);">Delete</a></td>
                </logic:equal>
        </tr>
    </logic:iterate>
</table>
</html:form>
</logic:notPresent>
</body>
</html>